﻿using System;
using System.Web.UI;

namespace SBACN.WebSite.Code
{
	public abstract class BaseControl : UserControl
	{
		public string MenuCode
		{
			get
			{
				if (SystemCode.Length >= 4)
				{
					return SystemCode.Substring(0, 4);
				}
				else
					return string.Empty;
			}
		}

		/// <summary>
		/// 当前页面的业务代码
		/// </summary>
		public string SystemCode
		{
			get
			{
				if (ViewState["SystemCode"] == null)
				{
					return string.Empty;
				}
				return ViewState["SystemCode"].ToString();
			}
			set
			{
				ViewState["SystemCode"] = value;
			}
		}

		/// <summary>
		/// 当前页面是否为EN菜单
		/// </summary>
		public bool IsEn
		{
			get
			{
				return Request["en"] == "1";
			}
		}

		/// <summary>
		/// 根据Request中的st参数，初始化页面的业务代码
		/// </summary>
		/// <param name="e"></param>
		protected override void OnInit(EventArgs e)
		{
			if (!string.IsNullOrWhiteSpace(Request["st"]))
				this.SystemCode = Request["st"].Trim();
			base.OnInit(e);
		}
	}
}